package de.stoneageracer.vehicles;

import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.VehicleControl;
import com.jme3.scene.Node;
import de.stoneageracer.core.RacingApplication;

/**
 * 
 * @author Basti
 */
public class Car extends VehicleControl{
    
    /**
     * the node containing all model-details
     */
    public Node node = null;
    /**
     * location where your model is safed (ususally an ogre-xml-file or a scene)
     */
    public String modelUrl = null;
    /**
     * the name of the Car "body" spatial in your scene/model
     */
    public String carUrl = "Car";
    /**
     * the name of the Car "front right wheel" spatial in your scene/model
     */
    public String wheelFrontRight = "WheelFrontRight";
    /**
     * the name of the Car "front left wheel" spatial in your scene/model
     */
    public String wheelFrontLeft = "WheelFrontLeft";
    /**
     * the name of the Car "back right wheel" spatial in your scene/model
     */
    public String wheelBackRight = "WheelBackRight";
    /**
     * the name of the Car "back left wheel" spatial in your scene/model
     */
    public String wheelBackLeft = "WheelBackLeft";
    
    /**
     * creates a Car. By default with the following values:
     * public String carUrl = "Car";
     * public String wheelFrontRight = "WheelFrontRight";
     * public String wheelFrontLeft = "WheelFrontLeft";
     * public String wheelBackRight = "WheelBackRight";
     * public String wheelBackLeft = "WheelBackLeft";
     * @param modelUrl location where your model is safed (ususally an ogre-xml-file or a scene)
     */
    public Car(String modelUrl){
        this.modelUrl = modelUrl;
    }
    
    /**
     * adds a steerable playerCar to the given node
     * @param node the Node on which you want to add your Car
     * @param x x-position to add the car
     * @param y y-position to add the car
     * @param z z-position to add the car
     * @param app a RacingApplication for handling (usually the one this method is called from)
     */
    public void addTo(Node node,float x,float y,float z,RacingApplication app){
        app.buildPlayer(this,x,y,z);
    }
    
    public void init(CollisionShape carHull,float mass){
        collisionShape = carHull;
        this.mass = mass;
        rebuildRigidBody();
    }
}